package com.highcom.converter;


import org.springframework.core.convert.converter.Converter;


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

//自定义类型转换器，实现Converter接口。
public class MyDateConvert implements Converter<String, Date> {
    @Override
    public Date convert(String source) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-DD");
        Date date = null;
        try {
            System.out.println("开始格式转换---");
            date = df.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        return date;
    }
}
